namespace SimpleWebServices.Web.Routing
{
    using Xunit;

    public sealed class RouteNameFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(new ObjectExpectations<RouteName>()
                .DerivesFrom<ValueObject<RouteName>>()
                .IsConcreteClass()
                .IsSealed()
                .HasDefaultConstructor()
                .IsNotDecorated()
                .Result);
        }

        [Fact]
        public void ctor()
        {
            Assert.NotNull(new RouteName());
        }

        [Fact]
        public void ctor_string()
        {
            Assert.NotNull(new RouteName("example"));
        }

        [Fact]
        public void prop_Length_get()
        {
            RouteName obj = new RouteName("example");

            int expected = obj.Value.Length;
            int actual = obj.Length;

            Assert.Equal<int>(expected, actual);
        }

        [Fact]
        public void prop_Value()
        {
            Assert.True(new PropertyExpectations(typeof(RouteName).GetProperty("Value"))
                .DefaultValueIsNull()
                .ArgumentNullException()
                .ArgumentOutOfRangeException(string.Empty)
                .FormatException("/example")
                .FormatException("example/")
                .Set("example")
                .IsNotDecorated()
                .Result);
        }

        [Fact]
        public void opImplicit_RouteName_string()
        {
            RouteName expected = new RouteName("example");
            RouteName actual = "example";

            Assert.Equal<RouteName>(expected, actual);
        }

        [Fact]
        public void opImplicit_RouteName_stringNull()
        {
            RouteName expected = null;
            RouteName actual = null as string;

            Assert.Equal<RouteName>(expected, actual);
        }

        [Fact]
        public void opImplicit_string_RouteName()
        {
            string expected = "example";
            string actual = new RouteName(expected);

            Assert.Equal<string>(expected, actual);
        }

        [Fact]
        public void opImplicit_string_RouteNameNull()
        {
            string expected = null;
            string actual = null as RouteName;

            Assert.Equal<string>(expected, actual);
        }

        [Fact]
        public void op_ToString()
        {
            string expected = "example";
            string actual = new RouteName(expected).ToString();

            Assert.Equal<string>(expected, actual);
        }
    }
}